package com.me.libgdx_test;

import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.utils.Align;
//This class creates an achievement object that can be attached to any stage
public class ClassAchievementMarket extends AbstractClassAchievement{
	
	ClassUnlockCost cost;
	private int x_margin;
	ClassAchievementMarket(ActivityMain game, Point dimensions, ClassUnlockCost cost){
		super(game,dimensions);	
		this.cost = cost;
		x_margin = 0;
		populate_achievement_object();
	}
	void populate_achievement_object(){
		
		refresh_achievements();
		
		int x_space = dimensions.x/50;
		int y_space = dimensions.y/40;
		int y_margin = 0;

		//level_icon.setPosition(x_space*10, y_margin);
		level_icon.setPosition(x_space*8, y_margin);
		level_icon.setSize(dimensions.x/30,dimensions.x/30);
		//achievement_group.addActor(level_icon);
		
		//x_margin += level_icon.getX() + level_icon.getWidth() + x_space;
		
		final Label level_label = new Label(String.valueOf(cost.level), skin.get_alternate_skin());
		level_label.setFontScale(1);
		level_label.setAlignment(Align.center);
		level_label.setPosition(level_icon.getX() + (int) 2.5*level_icon.getWidth()/10, level_label.getY() + y_space/2);
		level_label.setSize(dimensions.x/50,dimensions.x/50);
		//achievement_group.addActor(level_label);
		
		//x_margin += level_label.getWidth() + x_space/2;
		
		x_margin += level_icon.getX() + level_icon.getWidth() + x_space;

		honor_icon.setPosition(x_margin + honor_icon.getX(), y_margin + honor_icon.getY());
		honor_icon.setSize(dimensions.x/30,dimensions.x/30);
		achievement_group.addActor(honor_icon);
		
		//x_margin += honor_icon.getWidth() + x_space;
		
		final Label honor_label = new Label(String.valueOf(cost.honor), skin.get_alternate_skin());
		honor_label.setFontScale(1);
		honor_label.setAlignment(Align.center);
		honor_label.setPosition(honor_icon.getX() + (int) 2.5*honor_icon.getWidth()/10, honor_label.getY() + y_space/2);
		honor_label.setSize(dimensions.x/50,dimensions.x/50);
		achievement_group.addActor(honor_label);
		
		//x_margin += honor_label.getWidth() + x_space/2;
		
		x_margin += honor_icon.getWidth() + x_space;
		
		gold_icon.setPosition(x_margin + gold_icon.getX(), y_margin + gold_icon.getY() - y_space);
		gold_icon.setSize(dimensions.x/20,dimensions.x/20);
		achievement_group.addActor(gold_icon);
		
		//x_margin += gold_icon.getWidth() + x_space;
		
		final Label gold_label = new Label(String.valueOf(cost.gold), skin.get_alternate_skin());
		gold_label.setFontScale(1);
		gold_label.setAlignment(Align.center);
		gold_label.setPosition(gold_icon.getX() + 3*gold_icon.getWidth()/10, gold_label.getY());
		gold_label.setSize(dimensions.x/40,dimensions.x/40);
		achievement_group.addActor(gold_label);
		
		x_margin += gold_icon.getWidth() + x_space;

	}
	public int get_width(){
		return x_margin;
	}
	public Group get_achievement_group(){
		return achievement_group;
	}
}
